package HomeWWork.Home2;

import java.util.*;

/*
 *@Student 张策
 */
public class Main {
    public static void main1(String[] args) {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("jack",650);
        map.put("tom",1200);
        map.put("Smith",2900);
        map.put("jack",2600);
        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        for (Map.Entry<String, Integer> x:entries){
            System.out.println(x.getKey()+x.getValue());
            map.put(x.getKey(),x.getValue()+100);
            System.out.println(x.getKey()+x.getValue());
        }
    }

    public static void main2(String[] args) {
        HashSet set = new HashSet();
        Work p1 = new Work("AA", 100);
        Work p2 = new Work("BB", 101);
        set.add(p1);
        set.add(p2);
        p1.name="cc";
        set.remove(p1);
        System.out.println(set);
    }

    public static void main(String[] args) {
        Vector<Object> vec = new Vector<>();
        vec.add(1);
        vec.add(1);
    }
}
class Work{
    String name;
    int money;

    public Work(String name, int money) {
        this.name = name;
        this.money = money;
    }

    @Override
    public String toString() {
        return "Work{" +
                "name='" + name + '\'' +
                ", money=" + money +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Work work = (Work) o;
        return money == work.money && Objects.equals(name, work.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, money);
    }
}
